<?php

namespace app\api\model;

use think\facade\Db;
use think\Model;
use think\model\concern\SoftDelete;

class User extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    public static function checkVip($uid)
    {
        $res = self::where(['id' => $uid])->value('vip_time');
        return $res > time() ? true : false;
    }
    public function getAvatorAttr($val)
    {
        $path = app()->getRootPath() . 'public' . $val;
        if (empty($val) || !file_exists($path)) {
            return addHost('/static/images/avator/avator.gif');
        }
        return addHost($val);
    }
}
